<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function copy(data) {
            if (get(data) == 'Array') {
                var reg = [];
            }
            else if (get(data) == 'Object') {
                var reg = [];
            }
            else {
                return data;
            }

            for (let key in data) {
                if (get(data[key]) == 'Object' || get(data[key]) == 'Array') {
                    reg[key] = copy(data[key]);
                }
                else {
                    reg[key] = data[key];
                }
            }
            return reg;
        }
        function get(data) {
            return Object.prototype.toString.call(data).slice(8, -1);
        }
        let arr = copy([1, 2, 3, 4, 5, 6, 7, 8, 9]);
        console.log(arr);
    </script>
</body>

</html>